package com.dragon.client.controller.auth;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.common.model.ResponseData;
import com.dragon.logical.service.auth.IOperationLogService;
import com.dragon.repository.domain.dto.OperationLogDTO;
import com.dragon.repository.entity.OperationLog;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户操作日志 前端控制器
 * </p>
 *
 * @author sy
 * @since 2023-06-16
 */
@RestController
@RequestMapping("operationLog")
@Api(tags = "日志管理")
public class OperationLogController {


    @Autowired
    IOperationLogService service;


    @GetMapping("page")
    @ApiOperation(value = "分页列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "adminId",required = false,type = "int",value = "用户id"),
            @ApiImplicitParam(name = "username",required = false,type = "string",value = "用户名称"),
            @ApiImplicitParam(name = "page",required = true,type = "int",value = "页码"),
            @ApiImplicitParam(name = "limit",required = true,type = "int",value = "条数")
    })
    public ResponseData<List<OperationLogDTO>> selectPage(@RequestParam(required = false) Integer adminId,@RequestParam(required = false) String username, @RequestParam Integer page,@RequestParam Integer limit){
        Page<OperationLog> list = service.selectPage(adminId,username,page,limit);
        return ResponseData.success(OperationLogDTO.convertList(list.getRecords()),list.getTotal());
    }
}
